<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>05.并发访问</title>
</head>
<body>
<div id="app">

</div>
<!--引入vue-->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<!--引入Axios-->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    //1.创建一个查询所有请求
    function findAll() {
        return axios.get("http://localhost:8989/user/findAll?name=xiaochen");
    }

    //2.创建一个保存的请求
    function save() {
        return axios.post("http://localhost:8989/user/save", {
            username: "xiaochen",
            age: 23,
            email: "xiaochen@zparkhr.com",
            phone: 13260426185
        });
    }

    //3.并发执行 spread
    axios.all([findAll(), save()]).then(
        axios.spread(function (res1, res2) {
            console.log(res1.data);
            console.log(res2.data);
        })
    );
    const app = new Vue({
        el: "#app",
        data: {},
        methods: {}
    });
</script>
</body>
</html>